package com.example.vaccine.controller;

import com.example.vaccine.VO.PageVO;
import com.example.vaccine.VO.ResultVO;
import com.example.vaccine.service.VaccineUsageService;
import com.example.vaccine.util.ResultVOUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Coisn
 * @since 2025-06-12
 */
@RestController
@RequestMapping("/vaccineUsage")
public class VaccineUsageController {

    @Autowired
    private VaccineUsageService vaccineUsageService;

    @Operation(summary = "查询医生疫苗领取记录分页列表", description = "根据医生ID和可选条件分页查询疫苗领取记录")
    @GetMapping("/list")
    public ResultVO getUsageList(
            @Parameter(description = "医生ID", required = true) @RequestParam Integer doctorId,
            @Parameter(description = "疫苗名称，模糊查询", required = false) @RequestParam(required = false) String vaccineName,
            @Parameter(description = "开始日期，格式yyyy-MM-dd", required = false) @RequestParam(required = false) String startDate,
            @Parameter(description = "结束日期，格式yyyy-MM-dd", required = false) @RequestParam(required = false) String endDate,
            @Parameter(description = "页码，从1开始", required = true) @RequestParam Integer page,
            @Parameter(description = "每页条数", required = true) @RequestParam Integer size) {

        // 调用服务层查询分页数据，传入参数
        PageVO pageVO = vaccineUsageService.queryUsageList(doctorId, vaccineName, startDate, endDate, page, size);

        return ResultVOUtil.success(pageVO);
    }
}
